package com.ivy;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.map.MapUtil;
import com.ivy.builder.IvyFlowBuilder;
import com.ivy.builder.json.IvyFlowBuilderEdge;
import com.ivy.builder.json.IvyFlowBuilderEdgeProp;
import com.ivy.builder.json.IvyFlowBuilderNode;
import com.ivy.builder.json.IvyFlowBuilderNodeProp;
import com.ivy.parser.IvyFlowParser;
import com.ivy.parser.execption.LiteFlowELException;
import com.yomahub.liteflow.enums.NodeTypeEnum;

public class MainIf {
    public static void main(String[] args) throws LiteFlowELException {   // 构建节点属性数据
        // IvyFlowBuilderNodeProp nodeProp0 = IvyFlowBuilderNodeProp.NEW().componentId("InputDecimal").componentName("输入组件")
        //         .cmpDataName("data0")
        //         .cmpData(MapUtil.builder("input", "20").build());
        // IvyFlowBuilderNodeProp nodeProp1 = IvyFlowBuilderNodeProp.NEW().componentId("GtAndE50").componentName("大于等于50")
        //         .cmpDataName("data1")
        //         .cmpData(MapUtil.builder("aaaa", "12312").build());
        // IvyFlowBuilderNodeProp nodeProp2 = IvyFlowBuilderNodeProp.NEW().componentId("B").componentName("组件B")
        //         .nodeType(NodeTypeEnum.COMMON)
        //         .cmpTag("123456")
        //         .cmpDataName("data2")
        //         .cmpData(MapUtil.builder("aaaa", "12312").build());
        // IvyFlowBuilderNodeProp nodeProp3 = IvyFlowBuilderNodeProp.NEW().componentId("C").componentName("组件C");
        // IvyFlowBuilderNodeProp nodeProp4 = IvyFlowBuilderNodeProp.NEW().componentId("D").componentName("组件D");
        // IvyFlowBuilderNodeProp nodeProp5 = IvyFlowBuilderNodeProp.NEW().componentId("E").componentName("组件E");
        //
        // // 构建节点数据(普通组件)
        // IvyFlowBuilderNode node0 = IvyFlowBuilderNode.NEW().id().type(NodeTypeEnum.COMMON).properties(nodeProp0);
        // IvyFlowBuilderNode node1 = IvyFlowBuilderNode.NEW().id().type(NodeTypeEnum.SWITCH).properties(nodeProp1);
        // IvyFlowBuilderNode node2 = IvyFlowBuilderNode.NEW().id().type(NodeTypeEnum.COMMON).properties(nodeProp2);
        // IvyFlowBuilderNode node3 = IvyFlowBuilderNode.NEW().id().type(NodeTypeEnum.COMMON).properties(nodeProp3);
        // IvyFlowBuilderNode node4 = IvyFlowBuilderNode.NEW().id().type(NodeTypeEnum.COMMON).properties(nodeProp4);
        // IvyFlowBuilderNode node5 = IvyFlowBuilderNode.NEW().id().type(NodeTypeEnum.COMMON).properties(nodeProp5);
        // // 构建连线属性数据
        // IvyFlowBuilderEdgeProp edgeProp12 = IvyFlowBuilderEdgeProp.NEW().linkType(1);
        // IvyFlowBuilderEdgeProp edgeProp13 = IvyFlowBuilderEdgeProp.NEW().linkType(1);
        // IvyFlowBuilderEdgeProp edgeProp14 = IvyFlowBuilderEdgeProp.NEW().linkType(1);
        // IvyFlowBuilderEdgeProp edgeProp15 = IvyFlowBuilderEdgeProp.NEW().linkType(2);
        // // 构建连线数据
        // IvyFlowBuilderEdge edge12 = IvyFlowBuilderEdge.NEW()
        //         .sourceNode(node1.getNode().getId())
        //         .targetNode(node2.getNode().getId())
        //         .properties(edgeProp12);
        // IvyFlowBuilderEdge edge13 = IvyFlowBuilderEdge.NEW()
        //         .sourceNode(node1.getNode().getId())
        //         .targetNode(node3.getNode().getId())
        //         .properties(edgeProp13);
        // IvyFlowBuilderEdge edge14 = IvyFlowBuilderEdge.NEW()
        //         .sourceNode(node1.getNode().getId())
        //         .targetNode(node4.getNode().getId())
        //         .properties(edgeProp14);
        // IvyFlowBuilderEdge edge15 = IvyFlowBuilderEdge.NEW()
        //         .sourceNode(node1.getNode().getId())
        //         .targetNode(node5.getNode().getId())
        //         .properties(edgeProp15);
        //
        // String json = IvyFlowBuilder.builderJson()
        //         .addNode(node0, node1, node2, node3, node4, node5)
        //         .addEdge(node0, node1)
        //         .addEdge(edge12)
        //         .addEdge(edge13)
        //         .addEdge(edge14)
        //         .addEdge(edge15)
        //         .toFormatJson();
        //
        // System.out.println(json);

        String json = FileUtil.readUtf8String("D:\\temp\\111\\el解析\\nodes1.json");
        String el = IvyFlowParser.parse(json, true);
        System.out.println(el);
    }
}
